home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Game
/
R
/
ROBOT WARRIORS 1.0.1.CPT
/
Robot Warriors
/
Example Robots
/
Wall Crawler
< prev
Wrap
Text File
|
1991-08-26
|
2KB
|
66 lines
; Robot Name: Rambo Wall Crawler
;
; Crawl around the outside wall looking for robots to shoot while trying
; to avoid colliding with other robots.
; Rambo Wall Crawler is tough and fast but can't see very far.
ARMOR 2
FIRE_RATE 1
FUEL_CAPACITY 2
ENGINE_SIZE 1
define safety_dist 29 ;Distance away from the wall when it's time to turn
define collide_dist 50 ;If we see a robot in our path this far away, turn
define delta -90 ;This defines our direction of travel
allocate count
40 to speed
0 to direction
0 to count
again
; Check for a wall and turn if too close to one
; This robot only moves up, down, left, or right. This makes
; it easy to check one of four walls depending on direction.
if direction = 0 then gosub dir0
if direction = 90 then gosub dir90
if direction = 180 then gosub dir180
if direction = 270 then gosub dir270
; every so often look in front to check for collision
count + 1 to count
if count = 5 then
direction to radar
if radar >= 0 then
if radar < collide_dist then
direction + delta to direction ; avoid collision
0 to count
end
end
end
aim + 10 to aim to radar ;Scan for a robot
if radar > 0 then radar to shot
if speed = 0 then
direction + delta to direction
40 to speed
end
goto again
dir0 ;Check for hitting the top wall
if y < safety_dist then direction + delta to direction
return
dir90 ;Check for hitting the right wall
if x+safety_dist > XMAX then direction + delta to direction
return
dir180 ;Check for hitting the bottom wall
if y+safety_dist > YMAX then direction + delta to direction
return
dir270 ;Check for hitting the left wall
if x < safety_dist then direction + delta to direction
return